package com.apes.fico.masterdata.gl.model;

import java.util.Arrays;
import java.util.List;

/**
 * @program: apestech
 * @description: 财务常量
 * @author: Chengxm
 * @create: 2018-12-27 16:30
 **/
public class AccountingModel {

    /*借方*/
    public final static String DEBIT = "0";

    /*贷方*/
    public final static String CREDIT = "1";

    /*左*/
    public final static String LEFT = "0";

    /*右*/
    public final static String RIGHT = "1";


    /**
     * 损益结转
     **/
    public final static String PLCF = "PLCF";
    /**
     * 普通转账
     **/
    public final static String OT = "OT";
    /**
     * 重分类
     **/
    public final static String GLRC = "GLRC";

    /**
     * 实时
     **/
    public final static String RT = "REAL_TIEM";

    /**
     * 日
     **/
    public final static String D = "D";

    /**
     * 月
     **/
    public final static String M = "M";

    /**
     * 季
     **/
    public final static String S = "S";

    /**
     * 年
     **/
    public final static String Y = "Y";


    /**
     * 加
     **/
    public final static String PLUS = "+";

    /**
     * 减
     **/
    public final static String MINUS = "-";

    public String getPath(AccountingSystem accSystem, String code) {
        String rule = accSystem.getAccIdRule();
        List l = Arrays.asList(rule.split("/"));
        int iLen = 0;
        String path = "";
        int iKMID = code.length();
        for (int i = 0; i < l.size(); i++) {
            int j = Integer.parseInt(l.get(i).toString());
            if (iLen + j > iKMID) {
                break;
            }
            String pathCODE = code.substring(iLen, iLen + j);
            path = path != "" ? path + "/" + pathCODE : pathCODE;
            iLen = iLen + j;
        }
        return path;
    }
}
